package com.ss.android.article.base.feature.detail.presenter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.detail.model.MixedAdsData;
import com.ss.android.article.base.feature.detail.model.CommentWrapper;
import com.ss.android.article.base.feature.feed.FeedOnMovedToScrapHeapListener;
import com.ss.android.article.base.ui.AdjustImageView;
import com.ss.android.article.browser.R;
import com.ss.android.b.a.AdsAppItem;
import com.ss.android.b.a.AdsAppItem.b;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.image.model.ImageInfo;

public final class i implements View.OnClickListener, FeedOnMovedToScrapHeapListener {
    public Context a;
    public View b;
    public View c;
    public View d;
    public AdjustImageView e;
    public TextView f;
    public TextView g;
    private MixedAdsData h;
    private int i;
    private ImageLoader j;
    private boolean k;
    private String l;
    private boolean m;

    public i(Context arg2, ImageLoader arg3) {

        this.k = false;
        this.a = arg2;
        this.a.getResources();
        AppData.getInstance();
        this.j = arg3;
    }

    public final void a(CommentWrapper arg8, boolean arg9) {
        MixedAdsData v6 = null;
        int v2 = 3;
        if(arg8 != null && arg8.cellType == v2) {
            this.m = arg9;
            this.h = v6;
            this.l = "comment_ad";
            if(arg8.d == v2) {
                if(arg8.mMixedAdsData != null) {
                    this.h = arg8.mMixedAdsData;
                    if(this.k != AppData.isNightMode()) {
                        this.k = AppData.isNightMode();
                        this.e.setBackgroundResource(com.ss.android.article.browser.R.drawable.detail_ad_banner_bg);
                        this.g.setTextColor(ContextCompat.getColorStateList(this.a, R.color.ssxinzi8));
                        this.g.setBackgroundResource(com.ss.android.article.browser.R.drawable.detail_ad_taobao_image_lable);
                        this.f.setTextColor(ContextCompat.getColorStateList(this.a, R.color.ssxinzi3));
                        if(this.c != null) {
                            this.c.setBackgroundResource(com.ss.android.article.browser.R.color.ssxinxian1);
                        }
                    }

                    this.i = 1;
                    MixedAdsData v2_1 = this.h;
                    if(v2_1 != null && (v2_1.isValid())) {
                        this.d.setVisibility(View.VISIBLE);
                        UIUtils.setTextAndVisibility(this.f, v2_1.title);
                        if(this.j != null) {
                            this.j.loadImage(this.e, new ImageInfo(v2_1.d, ((String)null)), false);
                        }

                        this.d.setOnClickListener(((View.OnClickListener)this));
                        String v0 = v2_1.h;
                        if(android.support.design.a.isTextEmpty(v0)) {
                            v0 = this.a.getString(com.ss.android.article.browser.R.string.ad_label_info);
                        }

                        this.g.setText(((CharSequence)v0));
                        if(!this.m) {
                        }else {
                            BaseAdsData.trackAdShow(this.a, this.l, ((BaseAdsData) v2_1), 0);
                        }
                        View v2_2 = this.c;
                        int v0_1 = arg8.e == 2 ? View.INVISIBLE : View.VISIBLE;
                        v2_2.setVisibility(v0_1);
                        return;
                    }

                    this.d.setVisibility(View.GONE);
                }
                else {
                    return;
                }
            }

            View v2_2 = this.c;
            int v0_1 = arg8.e == 2 ? View.INVISIBLE : View.VISIBLE;
            v2_2.setVisibility(v0_1);
        }
    }

    public final void onMovedToScrapHeap() {
    }

    public final void onClick(View arg19) {
        if(this.i == 1) {
            Context v3 = this.a;
            MixedAdsData v2 = this.h;
            if(v2 != null) {
                if(((BaseAdsData)v2).adType == 1) {
                    AdsAppItem.a(v3, ((BaseAdsData)v2).openUrl, ((BaseAdsData)v2).pkg, ((BaseAdsData)v2).downloadUrl, ((BaseAdsData)v2).webUrl, ((BaseAdsData)v2).id, ((BaseAdsData)v2).appName, this.l, null, "download_confirm", ((BaseAdsData)v2).appName, "", ((BaseAdsData)v2).alertText, ((BaseAdsData)v2).logExtra);
                }
                else if(((BaseAdsData)v2).adType == 2) {
                    AdsAppItem.a(v3, ((BaseAdsData)v2).openUrl, ((BaseAdsData)v2).webUrl, ((BaseAdsData)v2).webTitle, ((BaseAdsData)v2).orientation, new b(this.a, this.l, "click", ((BaseAdsData)v2).id, ((BaseAdsData)v2).logExtra));
                }
            }
        }
    }
}

